import { Injectable, Inject } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router, NavigationStart } from '@angular/router';

export class AddAccessGuard implements CanActivate {
    constructor( private router: Router, @Inject(DOCUMENT) private document: any ) {}
    canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
        if (localStorage.getItem('info')) {
          alert('系统已经检测到您的个人信息');
          this.router.navigate(['index-page']);
        } else {
          return true;
        }
    }
}
